import request from '@/utils/request'

// 创建订单（从购物车结算）
export const createOrder = (data) => {
  return request({
    url: '/order/create',
    method: 'post',
    data
  })
}

// 获取订单列表
export const getOrderList = (params) => {
  return request({
    url: '/order/list',
    method: 'get',
    params
  })
}

// 获取订单详情
export const getOrderDetail = (id) => {
  return request({
    url: `/order/${id}`,
    method: 'get'
  })
}

// 取消订单
export const cancelOrder = (id) => {
  return request({
    url: `/order/${id}/cancel`,
    method: 'put'
  })
}

// 订单支付
export const payOrder = (id, data) => {
  return request({
    url: `/order/${id}/pay`,
    method: 'post',
    data
  })
}

// 退货申请
export const refundOrder = (id, data) => {
  return request({
    url: `/order/${id}/refund`,
    method: 'post',
    data
  })
}

// 处理退货
export const handleRefund = (id, data) => {
  return request({
    url: `/order/${id}/handleRefund`,
    method: 'put',
    data
  })
}

// 管理员/员工查询所有订单列表
export const getAdminOrderList = (params) => {
  return request({
    url: '/order/admin/list',
    method: 'get',
    params
  })
}

// 管理员/员工获取订单详情（无权限限制）
export const getAdminOrderDetail = (id) => {
  return request({
    url: `/order/admin/${id}`,
    method: 'get'
  })
}

// 发货
export const shipOrder = (id) => {
  return request({
    url: `/order/${id}/ship`,
    method: 'put'
  })
}

// 确认收货
export const receiveOrder = (id) => {
  return request({
    url: `/order/${id}/receive`,
    method: 'put'
  })
}

// 完成订单
export const completeOrder = (id) => {
  return request({
    url: `/order/${id}/complete`,
    method: 'put'
  })
}
















